package top.ckxgzxa.newscms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.ckxgzxa.newscms.entity.User;
import top.ckxgzxa.newscms.mapper.UserMapper;
import top.ckxgzxa.newscms.service.UserService;

import java.util.List;
import java.util.Map;

/**
 * @author 赵希奥
 * @date 2022/4/29 8:49
 * @gitHub https://github.com/CKXGZXA
 * @gitee https://gitee.com/ckxgzxa
 * @description:
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<Map<String, Object>> getUserByName(String name) {
        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(User::getUsername, name)
                .select(User::getUsername, User::getAge, User::getEmail);
        return userMapper.selectMaps(queryWrapper);
    }
}
